#ifndef LOCK_H
#define LOCK_H
#include "common.h"

#define LOCK_DATAINDEX "lock/c-sf_dataIndex.lock"
#define LOCK_SITES_SUBMITTED "lock/c-sf_sites_submitted.lock"
#define LOCK_BUGS_REPORTED "lock/c-sf_bugs_reported.lock"

int lock_reg(int fd,int cmd,int type,off_t offset,int whence,off_t len);

#define read_lock(fd,offset,whence,len) \
		lock_reg((fd),F_SETLK,F_RDLCK,(offset),(whence),(len))
#define readw_lock(fd,offset,whence,len) \
		lock_reg((fd),F_SETLKW,F_RDLCK,(offset),(whence),(len))
#define write_lock(fd,offset,whence,len) \
		lock_reg((fd),F_SETLK,F_WRLCK,(offset),(whence),(len))
#define writew_lock(fd,offset,whence,len) \
		lock_reg((fd),F_SETLKW,F_WRLCK,(offset),(whence),(len))
#define un_lock(fd,offset,whence,len) \
		lock_reg((fd),F_SETLK,F_UNLCK,(offset),(whence),(len))

#endif
